﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

public partial class Visitor_LookUpZIP : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void imgbFind_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["OPOConnectionString"].ToString());
        cnn.Open();
        SqlCommand cmd = new SqlCommand("Select ZipCode from City where CityName like '%" + txtCName.Text + "%'", cnn);
        SqlDataReader dread = cmd.ExecuteReader();
        if (txtCName.Text == "")
        {
            ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "ShowMessage()", true);
        }
        else
        {
            while (dread.Read())
                lblResult.Text = dread.GetString(0);
         
        }
    }
}